package com.wind.controller;

import com.wind.config.JwtProperties;
import com.wind.util.JwtTokenUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;


public class BaseController {

    @Autowired
    protected JwtProperties jwtProperties;
    @Autowired
    protected  JwtTokenUtil jwtTokenUtil;

    protected Logger logger = LoggerFactory.getLogger(getClass());

    protected String getTokenId(HttpServletRequest request){
        String requestHeader = request.getHeader(jwtProperties.getHeader());
        String token = requestHeader.substring(7);
        return jwtTokenUtil.getUsernameFromToken(token);
    }
}
